<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        //Math对象
        var PI = Math.PI;//圆周率
        console.log(PI);
        console.log(Math.abs(-1));//绝对值
        console.log(Math.floor(2.9));//向下取整
        console.log(Math.ceil(2.1));//向上取整
        console.log(Math.round(2.1));//四舍五入
        console.log(Math.round(2.9));//四舍五入

        console.log(Math.random());//随机数
        console.log(Math.floor(Math.random()*11))//取0~10
        function Random(min,max){
            console.log(Math.random()*(max-min)+min);
        };
        //date对象
        var date = new Date();
        console.log(date);
        var year =date.getFullYear();
        var month=date.getMonth()+1;
        var day=date.getDate();
        console.log(year+'-'+month+'-'+day);
        function pluszero(x){
                if (x<10){
                    x='0'+x;
                }
                return x;
            }
        function Time(){
            var date =new Date();
            var year =date.getFullYear();
            var month= date.getMonth()+1;
            var day= date.getDate();
            var hour= date.getHours();
            var minute= date.getMinutes();
            var second=  date.getSeconds();
            
            console.log(year+'-'+ pluszero(month)+'-'+ pluszero(day)+' '+pluszero(hour)+'-'+pluszero(minute)+'-'+pluszero(second));
        }
        Time();          
        //倒计时
        function countdown(datex){
            var date1= new Date(datex);
            var time= date1-date;
            var d=Math.floor(time/1000/60/60/24);
            var h=Math.floor(time/1000/60/60%24);
            var m=Math.floor(time/1000/60%60);
            var s=Math.floor(time/1000%60);
            console.log(pluszero(d)+'-'+pluszero(h)+'-'+pluszero(m)+'-'+pluszero(s));
        }
        countdown('2020-02-23 00:00:00');
        //数据
        //排序
        var points=[20,789,23,236,32];
        points.sort(function(a,b){return a-b});
        console.log(points);
        console.log(points.indexOf(23));//返回数字下标 lastindexOf返回最后一次出现的位置
        var str = points.join('-');
        console.log(str);//会显示用-隔开的一整个数组
        points.forEach(function(item){
            console.log(item);
        });//遍历数组，不能break等；
        var arr2=[1,2,3,4,5,6];
        arr2.splice(2,2,3,3);//从第二个开始删除两个并添加3和3
        //字符串
        var str3='1,2,3,4,5';
        var arr3=str3.spilt(',');//分隔符
        console.log(arr3);
        console.log(str3.substring(2,4))//截取字符串(始，末)
        console.log(str3.substr(2,4))//截取字符串（始，长度）
        

</script>
</body>
</html>